import axios from 'axios'
import { MessageBox, Message } from 'element-ui'

const service = axios.create()

// response interceptor
service.interceptors.response.use(response => {
  const res = response.data

  // console.log(res);

  return res
}, error => {
  console.log('err' + error) // for debug
  Message({
    message: error.msg || 'Error',
    type: 'error',
    duration: 3 * 1000
  })
  return Promise.reject(error)
})

export default service